Floating Point Routines Single Precision

Diese Seite gibt es auch auf Deutsch.


Description
These floating point routines are exactly the same I used in Arcquake. They are not IEEE compliant. Some functions round correctly. Everyone feeling he needs them should click here.

Functions for Converting
int FIX_FLOAT_MEM_SL(float *f, int s);              // (int)(f*2^s)
int FIXCEIL_FLOAT_MEM_SL(float *f, int s);          // (int)ceil(f*2^s)
void FLOAT_FIX_MEM(int i, float *f);                // f=(float)i;
Some Macros
void FLOAT_COPY(float *d, float *s);                // d=s;
void FLOAT_ABS(float *d, float *s);                 // d=fabs(s);
void FLOAT_NEG(float *d, float *s);                 // d=-s;
Arithmetic Functions
int CMP_FLOAT_MEM(float *a, float *b);              // int?0=a?b
void FLOAT_SL(float *d, float *s, int s);           // d=s*2^s;
void FLOAT_SQRT(float *d, float *s);                // d=sqrt(s);
void ADD_FLOAT_MEM(float *s, float *a, float *b);   // s=a+b; 
void SUB_FLOAT_MEM(float *s, float *a, float *b);   // s=a-b;
void MUL_FLOAT_MEM(float *s, float *a, float *b);   // s=a*b;
void DIV_FLOAT_MEM(float *s, float *a, float *b);   // s=a/b;
void ADotProduct(float *a, float b[3], float c[3]); // a=b[0]*c[0]+...
void AVectorCopy(float a[3], float b[3]);           // a[0]=b[0]; ...
Functions used by the above functions
int LMUL(int a, int b, int shift);                  // (a*b)>>shift
int FDIV(unsigned int a, unsigned int b);           // a/b
int FDIVS(int a, int b);                            // a/b
int FDIV64(int l, int h, int d);                    // (h*2^32+l)/d


And back!

E-mail: mail@peter-teichmann.de